// 'use strict';
//获取token
var hwtoken = getQueryString('hwtoken');
token = hwtoken;

//初始化服务参数(默认值配置在hwDas.js中)
hwDas.token = token;
hwDas.appinfo.callCode = callCode;
hwDas.appinfo.module = module;
hwDas.appinfo.system = system;

if (hwDas.hosts.length <= 0) {
    hwDas.hosts.push(hostsurl);
}

// 定义是否加载完成的变量
let treeDone = false;
// 初始化页面id 为空
let id = '';
// 初始化当前模块为空数组
let nowModel = [];
//存储功能树
let apptree;
//存储登陆用户
let login;
// 分析布局方式
let layout;
// 生成dhtmlx树
let tree = new dhtmlXTreeObject('SelectTree', '100%', '100%', 0);
//预定义行列
let c = 0,
    r = 0;

// 功能导航模块
function modelFc(opts) {
    this.config = {
            wrap: '',
            modelArr: opts.modelArr
        }
        //初始化方法
    this.init(opts);
}

modelFc.prototype.init = function(opts) {
    let self = this;
    let _config = self.config;
    $(_config.modelArr).each((index, item) => {
        if (item.module_picture === "") {
            item.module_picture = './images/9.png'
        }
        let html = `<div class="f-l eachModalList">
                <a  class='open-short c-p' data-id=${item.module_id} >
                    <img src="${item.module_picture}" alt="">
                    <p>${item.module_name}</p>
                </a>
            </div>`;
        $(html).insertBefore($('#addModel'))
    })
}

// tab页
function tabFc(opts) {
    this.config = {
            wrap: '',
            tabArr: ''
        }
        //初始化方法
    this.init(opts)
}

tabFc.prototype = {
    init: function(opts) {
        this.config = $.extend(this.config, opts || {});
        let self = this;
        let _config = self.config;
        $(_config.wrap).each((index, item) => {
            // 生成页面
            self._renderHtml(item);
            //绑定方法
            self._bindFc(item);
        })
    },
    _renderHtml: function(wrap) {
        let self = this;
        let _config = self.config;
        let tabUl = $(`<ul class="g-tab-list clearfix"></ul>`);
        let len = _config.tabArr.length;
        $(_config.tabArr).each((index, item) => {
            let tabLi;
            if (index === 0) {
                tabLi = $(`<li class="f-l tabLi active">${item.tab}</li>`);
            } else {
                tabLi = $(`<li class="f-l tabLi">${item.tab}</li>`);
            }
            $(tabUl).append($(tabLi))
        })
        $(_config.wrap).append($(tabUl))
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                let tabContent;
                if (i === 0) {
                    tabContent = $(`<div class="g-tab-content "></div>`);
                } else {
                    tabContent = $(`<div class="g-tab-content d-n"></div>`);
                }
                let Slen = _config.tabArr[i].items.length;
                let tabSUl = $(`<ul class="g-stab-list clearfix"></ul>`);
                let tabSContent;
                $(_config.tabArr[i].items).each((index, item) => {
                    let tabSLi;
                    if (index === 0) {
                        tabSLi = $(`<li class="f-l tabSLi "><a class='active' target='_blank' data-url="${item.url}" >${item.tab}</a></li>`);
                    } else {
                        tabSLi = $(`<li class="f-l tabSLi"><a target='_blank' data-url="${item.url}" >${item.tab}</a></li>`);
                    }
                    $(tabSUl).append($(tabSLi));
                })
                $(tabContent).append(`<img src="./images/db.png" alt="">`);
                $(tabContent).append($(tabSUl));
                if (Slen > 0) {
                    for (var j = 0; j < Slen; j++) {
                        if (j === 0) {
                            tabSContent = $(`<ul class="g-stab-content "></ul>`);
                        } else {
                            tabSContent = $(`<ul class="g-stab-content d-n"></ul>`);
                        }
                        $(tabContent).append($(tabSContent))
                    }
                }
                $(_config.tabArr[i].items).each((index, item) => {
                    let more = $(`<a target='_blank' class="loadmore" href="${item.url}">查看更多</a>`)
                    $(tabContent).eq(index).append($(more))
                })
                $(_config.wrap).append($(tabContent));
            }
        }
    },
    _bindFc: function(wrap) {
        let self = this;
        let _config = self.config;
        let nowIndex = 0
        $(`${_config.wrap} .g-tab-list li`).each((index, item) => {
            $(item).bind('click', function() {
                nowIndex = index
                let that = $(this)
                $(`${_config.wrap} .g-tab-list li`).removeClass('active')
                that.addClass('active')
                $(`${_config.wrap}   div.g-tab-content`).addClass('d-n')
                $(`${_config.wrap} .g-tab-content`).eq(index).removeClass('d-n')

                $(`${_config.wrap} .g-tab-content`).eq(nowIndex).find(`.g-stab-list li`).each((index, item) => {
                    $(item).find('a').bind('click', function() {
                        let that = $(this)
                        that.parents(`.g-stab-list`).find(`a`).removeClass('active')
                        that.addClass('active')
                        that.parents(`div.g-tab-content`).find(`.g-stab-content`).addClass('d-n')
                        that.parents(`div.g-tab-content`).find(`.g-stab-content`).eq(index).removeClass('d-n')
                        that.parents(`div.g-tab-content`).find('.loadmore').attr('href', `${$(this).attr('data-url')}`)
                    })
                })
            })
            if ($(`${_config.wrap} .g-tab-list li`).length > 0) {
                $(`${_config.wrap} .g-tab-list li`).eq(0).click()
            }
        })

    }
}

// 定义iframe 加载生成页面中的展示模块
let iframe = ` <iframe id="myiframe" frameborder="0" src="" style="margin:0 auto; height:500px;display:block;box-sizing:border-box; padding:0px 10px;border: 0px;overflow: auto;"></iframe>`
let renderIframe = function(col, row) {
    if (this instanceof renderIframe) {
        let S = new this[col](row)
        return S
    } else {
        return new renderIframe(col, row)
    }
}
renderIframe.prototype = {
    0: function(row) {
        let html = []
        return html;
    },
    1: function(row) {
        let html = []
        if (row === 1) {
            html.push($(iframe).addClass('pw100'))
        } else if (row > 1) {
            for (let i = 0; i < row; i++) {
                html.push($(iframe).addClass('pw100 f-l'))
            }
        } else {
            html = []
        }
        return html
    },
    2: function(row) {
        let html = []
        if (row === 1) {
            for (let i = 0; i < 2; i++) {
                html.push($(iframe).addClass('pw100'))
            }
        } else if (row > 1) {
            for (let a = 0; a < 2; a++) {
                for (let i = 0; i < row; i++) {
                    html.push($(iframe).addClass('pw50').addClass('f-l'))
                }
            }
        } else {
            html = []
        }
        return html
    }
}

//生成树
function CreateTree(data, sjdm) {
    var addFlag = false;
    var str = "";
    for (var i = 0; i < data.length; i++) {
        if (sjdm == data[i].parent_node_id) {
            if (addFlag) {
                str += ",";
            }
            str += "{ \"url\":\"" + data[i].node_id + "\",\"title\":\"" + data[i].node_name + "\"";
            str += CreateTree(data, data[i].node_id);
            str += "}";
            addFlag = true;
        }
    }
    var res = "";
    if (str.length > 0) {
        res = ",\"items\":[" + str + "]";
    }
    return res;
}

// 递归模块树
let createModuleTree = (data, pid) => {
    let result = [],
        temp
    for (let i in data) {
        if (data[Number(i)].parent_node_id === pid) {
            result.push(data[i].node_id)
            temp = createModuleTree(data, data[i].node_id);
            if (temp.length > 0) {
                data[i].items = temp
            }
        }
    }
    return result;
}


// 递归tabbar
let createTabTree = (data, pid) => {
    let result = [],
        temp
    for (let i in data) {
        if (data[Number(i)].pnode_id === pid) {
            result.push(data[i])
            temp = createTabTree(data, data[i].node_id);
            if (temp.length > 0) {
                data[i].items = temp
            }
        }
    }
    return result;
}

// 递归快捷方式树
let moduleTreeFc = (data, pid) => {
    let treeArray = []
    for (var j = 0; j < data.length; j++) {
        if (data[j]["node_id"] == pid) {
            data[j]["parent_node_id"] = 0;
        }
        treeArray.push([data[j]["node_id"], data[j]["parent_node_id"] == "" ? 0 : data[j]["parent_node_id"], data[j]["node_name"]]);
    }
    return treeArray
}
let times = 0;

//成功和失败的方法
const FUNCS = {
    errorFc: (e) => {

        if (times < 1) {
            alert('获取数据失败');
        }
        times++;
    },
    //金叉额敏获取工作台id
    checkPageSuccessFc: (data) => {
        let dt = data.data[0].datas
        id = dt[0].worktable_id
        layout = dt[0].layout_style
            //获取需要展示的模块内容
        GETDATA.moduleShow()

    },
    // 获取菜单树
    menuListSuccessFc: (data) => {
        let menu = CreateTree(data.data[0].datas, "0");
        menu = `{"data":{` + menu.substr(1, menu.length) + `}}`;
        let menuData = JSON.parse(menu);
        new menuList({ navWrap: '.nav-wrap', menuArrs: menuData.data.items });
    },
    // 获取滚动轮播内容
    sliderSuccessFc: (data) => {
        let slide = data.data[0].datas;
        new slider({ wrap: '#g-slider', sliderArrs: slide, isHwText: true, sliderTime: 5000 });
    },
    // 加载模块快捷方式
    modelSuccessFc: (data) => {
        let model = data.data[0].datas;
        if (model.length > 0) {
            $(model).each((index, item) => {
                nowModel.push({ id: item.module_id, type: '' });
            })
        }
        new modelFc({ wrap: '.g-modelNav', modelArr: model });
    },
    // 生成tabbar
    tabSuccessFc: (data) => {
        let tabData = tabdata.tabList;
        new tabFc({ wrap: '.infoBox', tabArr: tabData });
    },
    moduleSuccessFc: (data) => {
        let moduleData = createModuleTree(data.data[0].datas, "0");
    },
    // 功能模块书
    moduleTreeSuccessFc: (data) => {
        apptree = data.data[0].datas;
        $("#page-load").addClass('d-n');
        if (!treeDone) {
            let list = moduleTreeFc(data.data[0].datas, "0");
            tree.deleteChildItems(0);
            tree.loadJSArray(list);
            treeDone = true;
        }
        $(nowModel).each((index, item) => {
            tree.setCheck(item.id, 1);
        })
        $("#page-load").removeClass('d-n');
    },
    moduleShowSuccessFc: (data) => {
        let dt = data.data[0].datas;
        if (layout.length > 0) {
            c = Number(layout[0]);
            r = Number(layout[1]);
        }
        let html = renderIframe(c, r);
        if (dt.length > 0) {
            for (let i = 0; i < html.length; i++) {
                $(html[i]).attr('src', nowUrl + dt[i].module_url);
                $('.g-model').append($(html[i]));
            }
        }
    },
    picsLoadSuccessFc: (data) => {
        let dt = data.data[0].datas;
        if (dt.length > 0) {}
    }
}

//根据接口获取数据
const GETDATA = {
    //初始化页面id
    checkPage: function() {
        hwDas.get('/platform/v1/workTable/workTable', {}, {}, FUNCS.checkPageSuccessFc, FUNCS.errorFc, "json");
    },
    //加载导航
    menuList: function() {
        hwDas.get('/platform/v1/workTable/navBar', {}, { "desktopid": "80c97de0-1cad-4101-87d2-2eade9320df8" }, FUNCS.menuListSuccessFc, FUNCS.errorFc);
    },
    //加载轮播
    sliderList: function() {
        hwDas.get('/platform/v1/workTable/carouselPostion', {}, {}, FUNCS.sliderSuccessFc, FUNCS.errorFc, "json");
    },
    //加载快捷方式
    modelList: function() {
        hwDas.get('/platform/v1/workTable/shortcutModule', {}, {}, FUNCS.modelSuccessFc, FUNCS.errorFc, "json");
    },
    //
    // moduleList: function() {
    //     hwDas.get('/platform/v1/desktopTree', {}, { "desktopid": "80c97de0-1cad-4101-87d2-2eade9320df8", "pnodeid": "0" }, FUNCS.moduleSuccessFc, FUNCS.errorFc, "json")
    // },
    //加载tab页
    tabList: function() {
        hwDas.get('/platform/v1/workTable/notification', {}, {}, FUNCS.tabSuccessFc, FUNCS.errorFc, "json");
    },
    //加载模块树
    moduleTree: function() {
        hwDas.get('/platform/v1/desktopTree', {}, { "desktopid": "80c97de0-1cad-4101-87d2-2eade9320df8" }, FUNCS.moduleTreeSuccessFc, FUNCS.errorFc, "json");
    },
    //加载
    moduleShow: function() {
        hwDas.get('/platform/v1/workTable/exhibitModule', {}, {}, FUNCS.moduleShowSuccessFc, FUNCS.errorFc, "json");
    },
    //加载应用广告图
    picsLoad: function(id) {
        hwDas.get('/platform/v1/application', {}, { appid: id }, FUNCS.picsLoadSuccessFc, FUNCS.errorFc, "json");

    }

}


// 快捷方式模块添加
$('#addModel').on('click', function() {
    if (!treeDone) {
        GETDATA.moduleTree()
    } else {}

    layer.open({
        type: 1,
        shade: [0],
        area: ['790px', '480px'],
        anim: 2,
        maxmin: true, //开启最大化最小化按钮
        resize: true,
        content: $('#select'),
        title: '模块添加',
        shadeClose: false,
        moveOut: true,
        closeBtn: 1,
        scrollbar: true,
        zIndex: 100,
        success: function() {

        },
        end: function() {

        }
    })
})

// 模块添加
$('#addShowModel').on('click', function() {
    let M = {
        nodename: '模块添加',
        moduleId: '789456123',
        Url: '/work/show.html?hwtoken=' + token + "&id=" + id + "&c=" + c + "&r=" + r + "&title=" + title,
        nodeguid: '789456123',
        isFormShow: 0
    }
    top.pt.openModule(M)

})

// 广告图，点击左右箭头
$('.fa-chevron-left').on('click', function() {
    let index = $('.pics-box li').index($('.pics-box li.on'));
    if (index > 0) {
        $('.pics-box li').eq(index - 1).addClass('on').siblings().removeClass('on')
    }
})

// 广告图，点击左右箭头
$('.fa-chevron-right').on('click', function() {
    let index = $('.pics-box li').index($('.pics-box li.on'));
    if (index < $('.pics-box li').length - 1) {
        $('.pics-box li').eq(index + 1).addClass('on').siblings().removeClass('on')
    }
})

// 加载默认模块，初始化再datajs中
function defaultModule(arr) {
    $(arr).each((index, item) => {
        let html = `<div class="f-l eachModalList">
                <a  class='open-model c-p' data-Did=${item.sw_desktop_id} data-id=${item.module_id} target='_blank'>
                    <img src="${item.module_picture}" alt="">
                    <p>${item.module_name}</p>
                </a>
            </div>`;
        $(html).insertBefore($('#addModel'))
    })
}


// 初始化树
function initTree(treeObj) {
    treeObj.setSkin('dhx_web');
    treeObj.setImagePath("./lib/dhtmlx4.1/imgs/dhxtree_web/");
    treeObj.enableCheckBoxes(true);
    treeObj.attachEvent("onClick", function(id) {
        let nowId = apptree.filter(x => x.node_id === id)
        $('.detail-text').html(nowId[0].node_desc)
        GETDATA.picsLoad(id)
        if (treeObj.isItemChecked(id)) {
            treeObj.setCheck(id, 0);
        } else {
            treeObj.setCheck(id, 1);
        }
    });

    treeObj.attachEvent("onCheck", function(id) {
        let nowId = apptree.filter(x => x.node_id === id)
        $('.detail-text').html(nowId[0].node_desc)
        if (treeObj.isItemChecked(id)) {} else {}
    });
}

//用于生成uuid
function S4() {
    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}

function guid() {
    return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}

// 获取get参数
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
    var context = "";
    if (r != null)
        context = r[2];
    reg = null;
    r = null;
    return context == null || context == "" || context == "undefined" ? "" : context;
}

// 保存工作台id
function saveDefault(id) {
    let url = 'platform/v1/workTable/workTable';
    let p = {
        "worktableid": id,
        "operationtype": "insert"
    }
    hwDas.save(url, {}, {}, p, function(result) {
        if (!!result.isSucceed) {} else {
            alert('保存失败')
        }
    })
}

// 模块快捷方式保存
$('#ModuleSave').on('click', function() {
        if (id === '1') {
            id = guid()
            saveDefault(id)
        }
        let url = 'platform/v1/workTable/shortcutModule'
        let arr = []
        for (let i = 0; i < nowModel.length; i++) {
            let p = {
                "worktableid": id,
                "mmoduleid": nowModel[i].id,
                "operationtype": nowModel[i].type
            }
            arr.push(p)
        }
        let checkedModel = tree.getAllChecked().split(',')
        let params = { arr: arr }

        hwDas.save(url, {}, {}, arr, function(result) {
            if (!!result.isSucceed) {
                alert('保存成功')
                layer.closeAll()
                window.location.reload()
            } else {
                alert('保存失败')
            }
        })


    })
    // 模块快捷方式关闭
$('#ModuleClose').on('click', function() {
    layer.closeAll()
    if (parent && parent.layer) {
        parent.layer.closeAll();
    }
})

// 检查id是否在数组中
function checkId(arr, id) {
    let obj = {}
    for (var i = 0; i < arr.length; i++) {
        if (arr[i].id === id) {
            obj.flag = true
            obj.index = i
            break
        } else {
            obj.flag = false
            obj.index = -1
        }
    }
    return obj
}

// 判断是否在平台内加载

let isPt = (pt) => {
        if (pt === '0') {
            $('.g-header').addClass('d-n')
            $('.g-navWrap').addClass('d-n')
            $('.g-header-bg').addClass('d-n')
            $('.g-slider').addClass('d-n')
        } else {
            console.log(1)
            $('.g-header').removeClass('d-n')
            $('.g-navWrap').removeClass('d-n')
            $('.g-header-bg').removeClass('d-n')
            $('.g-slider').removeClass('d-n')
            GETDATA.menuList()
            GETDATA.sliderList()
        }
    }
    // 快捷方式点击事件
$('body').on('click', '.open-short', function() {
    let id = $(this).attr('data-id')
    let hasNodeId = apptree.filter(x => x.node_id === id)
    if (hasNodeId.length > 0) {
        if (hasNodeId[0].node_type === "category") {
            let M = {
                Did: hasNodeId[0].sw_desktop_id,
                Mid: id
            }
            top.pt.openOutTree(M.Did, M.Mid)
        } else {
            let M = {
                nodename: $(this).find('p').text(),
                moduleId: hasNodeId[0].ref_sw_module_id,
                Url: hasNodeId[0].startup_program_file,
                nodeguid: hasNodeId[0].node_id,
                isFormShow: 0
            }
            top.pt.openModule(M)
        }
    }
});
// 初始化再datajs中的模块点击事件
$('body').on('click', '.open-model', function() {
    let M = {
        Did: $(this).attr('data-Did'),
        Mid: $(this).attr('data-id')
    }
    top.pt.openOutTree(M.Did, M.Mid)
})

// 通知公告每一行标题的点击事件
$('body').on('click', '.notifyBox .g-stab-list li', function() {
    let index = $('.notifyBox .g-stab-list li').index($(this))
    $(this).addClass('active').siblings().removeClass('active')
    $('.notifyBox .g-stab-content').addClass('d-n')
    $('.notifyBox .g-stab-content').eq(index).removeClass('d-n')
    $('.notifyBox .loadmore').attr('href', $(this).attr('data-url'))
})

$(function() {
    //判断是否在平台内加载
    let pt = getQueryString('showmenu') || '';
    isPt(pt);

    // 加载模块书
    GETDATA.moduleTree();

    //初始化页面id
    GETDATA.checkPage();

    //加载模块快捷方式
    GETDATA.modelList();

    // 初始化tab页
    GETDATA.tabList();

    //
    // GETDATA.moduleList()

    //加载默认的模块快捷方式
    // defaultModule(config_data[code])

    //初始化树
    initTree(tree);

    tree.attachEvent("onCheck", function(id, state) {
        let checkid = checkId(nowModel, id)
        if (checkid.flag) {
            if (state === 0) {
                nowModel[checkid.index].type = 'delete'
            } else {
                nowModel[checkid.index].type = ''
            }
        } else {
            nowModel.push({ id: id, type: 'insert' })
        }
    });
    getLogin()
})





function getLogin() {
    var loginUrl = "platform/v1/UserManage";
    //接口参数--单元代码，格式:a,b 
    hwDas.get(loginUrl, {
        async: false
    }, {
        login: ''
    }, function(result) {
        login = result.data[0].datas[0].login;
        //通过json配置文件加载代办已办
        for (var i = 0; i < tabdata.tabList.length; i++) {
            for (var j = 0; j < tabdata.tabList[i].items.length; j++) {
                loadtodo(tabdata.tabList[i].items[j].ajax, login)
            }
        }
        notify(notifyUrl, '', 0);
        notify(ktUrl, '', 1);
        notify(kfUrl, '', 2);
        notify(gcUrl, '', 3);
    });


}

// 加载代办已办
let loadtodo = (url, id) => {
    $.ajax({
        url: url + id,
        type: 'get',
        datatype: 'json',
        success: function(data) {
            if (data.type === "待办假期") {
                $(data.data).each((index, item) => {
                    let li = $(`<li><a target='_blank' class="clearfix" href='http://10.84.11.60:8008/LeaderPt/Login/Index'><span class='f-l info-text'>${item.lCSLMCField}</span></a></li>`)
                    $('.infoBox .g-stab-content').eq(2).append($(li))
                })
            } else if (data.type === "待办合同") {
                $(data.data).each((index, item) => {
                    let li = $(`<li><a target='_blank' class="clearfix" href='http://10.246.0.200/login.aspx?systemid=55&pagekindflag=0&tempuserid=1IDtk6vUsGkFtxQy6LpYrWhnAiwX5zg75tAOgSdeLJU%3d'><span class='f-l info-text'>${item.businessNameField}</span></a></li>`)
                    $('.infoBox .g-stab-content').eq(0).append($(li))
                })
            } else if (data.type === "已办假期") {
                $(data.data).each((index, item) => {
                    let li = $(`<li><a target='_blank' class="clearfix" href='http://10.84.11.60:8008/LeaderPt/Login/Index'><span class='f-l info-text'>${item.lCSLMCField}</span></a></li>`)
                    $('.infoBox .g-stab-content').eq(5).append($(li))
                })
            } else if (data.type === "已办合同") {
                $(data.data).each((index, item) => {
                    let li = $(`<li><a target='_blank' class="clearfix" href='http://10.246.0.200/login.aspx?systemid=55&pagekindflag=0&tempuserid=1IDtk6vUsGkFtxQy6LpYrWhnAiwX5zg75tAOgSdeLJU%3d'><span class='f-l info-text'>${item.businessNameField}</span></a></li>`)
                    $('.infoBox .g-stab-content').eq(3).append($(li))
                })
            } else if (data.type === "待办oa") {
                $(data.data).each((index, item) => {
                    let li = $(`<li><a target='_blank' class="clearfix" href='http://oa1.jhpa.sinopec.com.cn/#access=yes'><span class='f-l info-text'>${item.lCSLMCField}</span></a></li>`)
                    $('.infoBox .g-stab-content').eq(1).append($(li))
                })
            } else if (data.type === "已办oa") {
                $(data.data).each((index, item) => {
                    let li = $(`<li><a target='_blank' class="clearfix" href='http://oa1.jhpa.sinopec.com.cn/#access=yes'><span class='f-l info-text'>${item.lCSLMCField}</span></a></li>`)
                    $('.infoBox .g-stab-content').eq(4).append($(li))
                })
            }
        }
    })
}

// 加载通知公告
let notify = (url, id, index) => {
    $.ajax({
        url: url + id,
        type: 'get',
        crossDomain: true,
        datatype: 'json',
        success: function(data) {
            let dt = JSON.parse(data.data);
            $(dt).each((index, item) => {
                let li = $(` <li><a class="clearfix" target='_blank' href='${notifyURL}${item.Infoid}'><span class='f-l info-text'>${item.Infotitle}</span><span class='f-r'>${item.Inforeleasetime.split(' ')[0]}</span></a></li>`)
                $('.notifyBox .g-stab-content').eq(index).append($(li))
            })
        },
        error: function(a, b, c) {}
    })
}